package com.per.mybootall.thread;

import org.springframework.stereotype.Component;

@Component
public class TestThread {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread1=new MyThread("接口实现线程1");
        MyThread myThread2=new MyThread("接口实现线程2");
        MyThread myThread3=new MyThread("接口实现线程3");

        Thread t1=new Thread(myThread1);
        Thread t2 =new Thread(myThread2);
        Thread t3 =new Thread(myThread3);

        t1.setPriority(Thread.MIN_PRIORITY) ;   // 优先级最低
        t2.setPriority(Thread.MAX_PRIORITY) ;   // 优先级最高
        t3.setPriority(Thread.NORM_PRIORITY) ;  // 优先级最中等

        t1.start();
        t2.start();
        t3.start();
        //线程休眠
        t1.sleep(1000);
        t2.sleep(1000);
        t3.sleep(1000);




        /**
         * 继承一般少用，尽量用接口
         * */
        MyThread2 myThread4=new MyThread2("继承实现线程1");
        MyThread2 myThread5=new MyThread2("继承实现线程2");

        Thread t4=new Thread(myThread3);
        Thread t5 =new Thread(myThread4);

        t4.start();
        t5.start();

        //线程休眠
        t4.sleep(1000);
        t5.sleep(1000);
    }



}
